package top.italks.webviewdemo.utils;

import android.content.Context;
import android.webkit.JavascriptInterface;
import android.widget.Toast;
import com.google.gson.Gson;
import org.json.JSONObject;
import top.italks.webviewdemo.bean.Car;

public class AndroidtoJs {

    private Context context;

    public AndroidtoJs(Context context) {
        this.context = context;
    }

    @JavascriptInterface
    public void hello(String msg, String param, int value) {
        Toast.makeText(context, msg + param + value, Toast.LENGTH_SHORT).show();
    }

    //JSON的字符串
    @JavascriptInterface
    public void checkIn(String msg) {
        Car car = new Gson().fromJson(msg, Car.class);
        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
    }
//    @JavascriptInterface
//    public void checkIn(Object[] msg) {
//        Toast.makeText(context,"123",Toast.LENGTH_SHORT).show();
//    }
}
